<!DOCTYPE html>
<html>
<head>
<title>借款管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../include/resources.html">
<script type="text/javascript">
    //$.fn.iframeWidthResize(640);//页面最小宽度设置
    var dataGrid;
    var winWidth =  900;
    var winHeight = 500;
    var verifyTitle = "投标记录";
    var verifyUrl =  "/modules/loan/borrow/tenderDetailPage.html";
    var verifyWinParmeters = "'{0}','"+verifyTitle+"',900,500,'"+verifyUrl+"'";
    
    var detailTitle = "更新抵押物";
    var detailUrl = "/modules/loan/borrow/getMortgageListPage.html"
    var detailWinParmeters = "'{0}','" + detailTitle+ "','"+ detailUrl + "'";
    var viewUrl = "${web_url}/invest/detail.html?borrowPreview=1"
    var starturl = "${web_url}/invest/";
    var endurl = "/detail.html?borrowPreview=1";
	var filmEndurl = "/103detail.html?borrowPreview=1";
    var viewWinParmeters = "'{0}','" + viewUrl + "'";
    var updateTitle = "修改借款";
    var updateUrl = "/modules/loan/borrow/borrowUpdatePage.html"
    
    $(function() {
        dataGrid = $('#borrowManagerList').datagrid({
            url : 'borrowList.html',
            fit : true,
            fitColumns : true,
            border : false,
            pagination : true,
            idField : 'id',
            pageSize : pageSize,
            pageNums :1,
            pageList : pageList,
            sortName : 'id',
            sortOrder : 'asc',
            checkOnSelect : false,
            selectOnCheck : false,
            nowrap : false,
		singleSelect:true,
               
            columns : [ [
              { field: 'id', title: '编号', width: 50,sortable:false },              
              { field: 'userName', title: '用户名', sortable:false },
              { field: 'realName', title: '借款人', width: 70, sortable:false },
              { field: 'name', title: '标名', width: 210, sortable:false },
				{ field: 'type', title: '类型', width: 60, sortable:false , 
				    formatter: function(value,row,index){
				      return borrowType(value);  
				      }  
				},
              { field: 'account', title: '借款金额(元)', width: 90, sortable:false,formatter: function(value,row,index){
            	  return value;
              }},
              
              { field: 'scales', title: '进度(%)', width: 70, sortable:false,formatter: function(value,row,index){
            	  return value;
              }},
              
              { field: 'apr', title: '利率(%)', width: 70, sortable:false,formatter: function(value,row,index){
            	  return value;
              } }, 
              { field: 'timeLimitTip', title: '期限', width: 80, sortable:false},
              { field: 'status', title: '状态', width: 80, sortable:false , 
					formatter: function(value,row,index){
  					if(row.status == -1){
  						return '用户撤回';
  					} else if(row.status == 0){
  						return '待初审';
  					}  else if (row.status == 1){
  						return '初审通过';
  					} else if (row.status == 1 && row.accountYes == row.account){
  						return '满标待审';
  					} else if (row.status == 1){
  						return '初审通过';
  					} else if (row.status == 2){
  						return '初审未通过';
  					} else if (row.status == 3){
  						return '复审通过';
  					} else if (row.status == 49 || row.status == 4){
  						return '复审未通过';
  					} else if (row.status == 59 ||row.status == 5){
  						return '管理员撤回';
  					} else if (row.status == 6){
  						return '还款中';
  					} else if (row.status == 7){
  						return '部分还款';
  					} else if (row.status == 8){
  						return '还款成功';
  					}  else {
  						return value;
  					}
  				}  
              },
              { field: 'style', title: '还款方式', width: 120, sortable:false , 
					formatter: function(value,row,index){
  					if (row.style == 1){
  						return '按月分期还款';
  					} else if (row.style == 2){
  						return '一次性还款';
  					} else if (row.style == 3){
  						return '每月还息到期还本';
  					}  else {
  						return value;
  					}
  				}  
              },
              { field : 'showInfo',
                  title : '其他信息',
                  width :75,
                  align:'center',
                  fixed:true,
                  formatter : function(value, row, index) {
                	  var mostAccount = row.mostAccount;
                	  if(mostAccount == 0){
                		  mostAccount = '无限制';
                	  }
  					var content = '<a href="javascript:void(0);" class="j-showInfo">查看<i class="iconfont">&#xe639;</i></a>'
  						+ '<div class="showInfoSingleDiv">'
  						+ '<div class="showInfo">'
  						+ '<em></em><h2>借款标信息</h2>'
  						+ '<ul>'
  						+ '<li>'
                  		+ '<span>投标笔数：</span>'
  						+ row.tenderTimes
  						+ '</li>'
  						+ '<li>'
                  		+ '<span>添加时间：</span>'
  						+ getLocalTime(row.addTime, 4)
  						+ '</li>'
  						+ '<li>'
                  		+ '<span>最低投标金额：</span>'
  						+ row.lowestAccount
  						+ '</li>'
  						+ '<li>'
                  		+ '<span>最高投标金额：</span>'
  						+ mostAccount
  						+ '</li>'
  						+ '<li>'
                  		+ '<span>应还款金额：</span>'
  						+ row.repaymentAccount
  						+ '</li>'
  						+ '<li>'
                  		+ '<span>已经还款金额：</span>'
  						+ row.repaymentYesAccount
  						+ '</li>'
  						
  						+ '</ul></div></div>';
  				return content;
  				}
  			},
              { field : 'action',
                title : '操作',
                width :75,
                fixed:true,
                align:'center',
                formatter : function(value, row, index) {
                	var str = '';
                  str += '<dl>';
                  str += '<dt><a href="javascript:void(0);" onclick="$.fn.dataGridOptions.closeFun('+row.id+',verifyTitle,winWidth,winHeight,verifyUrl);" title="'+verifyTitle+'">记录</a><i class="iconfont">&#xe639;</i></dt>' ;
                  str += '<dd>';
					if(row.type==103)
						str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.viewBorrowFunUuid('+row.uuid+',starturl,filmEndurl);" >预览</a>';
					else
                  str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.viewBorrowFunUuid('+row.uuid+',starturl,endurl);" >预览</a>';
                  if(row.category==2)
                	  str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.borroweditFun('+row.id+',updateTitle,winWidth,winHeight,updateUrl);" title="'+updateTitle+'">修改</a>';
                  str += '</dd>'
                  str +=  '</dl>'
                  return str;
                }
            } ] ]
        });
    });

	function exportExcel(){
		var url = "/modules/loan/borrow/exportExcelBorrow.html";
		var name=$("#name").val();
		var type=$("#type").val();
		var realName = $("#realName").val();
		var userName = $("#userName").val();
		var status = $("#status").val();
		var startTime = $("#startTime").val();
		var endTime = $("#endTime").val();
		var searchName = $("#searchName").val();
		var sou = "?userName=" + userName + "&realName=" + realName + "&status=" + status + "&startTime=" + startTime + "&endTime=" + endTime+"&type="+type+"&name="+name+"&searchName="+searchName;
		window.location.href = url + sou;
	}
</script>
</head>
<body style="padding:0 20px;" >
    <div class="easyui-layout" data-options="fit : true,border : false">
        <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
        	<div class="sLeft">
	            <form id="searchForm">
	            	<input type="text"  name="searchName" id="searchName" class="sInput" placeholder="输入借款人姓名/用户名/标名进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a><a href="javascript:;" class="advBtn" title="条件查询">条件查询 <i class="iconfont">&#xe638;</i></a>
                        <a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
	            </form>
            </div>
			<div class="sRight">
				<a id="a" onclick="exportExcel();" href="javascript:void(0);" class="addBtn">导出excel</a>
			</div>
            <form id="showAdw">
		        <ul class="showAdw" style="display:none;">
		        	<a href="javascript:void(0);"><i class="iconfont closeWin">&#xe63a;</i></a>
		        	<li><span>标的类型</span><select name="type" class="type" id="type"><option value="全部">全部</option><#list borrowConfigList as item><option value="${item.id}">${item.name}</option></#list></select></li>
		       		<li><span>借款人姓名</span><input type="text" name="realName" id="realName" autocomplete="off"/></li>
					<li><span>标名</span><input type="text" name="name" id="name" autocomplete="off"/></li>
		       		<li><span>用户名</span><input type="text" name="userName" id="userName" autocomplete="off"/></li>
		       		<li><span>状态</span><select name="status" id="status" class="type">
	                  <option value="99" selected="selected">全部</option>
	                  <option value="-1">用户撤回</option>
	                  <option value="0">待初审</option>
	                  <option value="1">初审通过</option>
	                  <option value="2">初审未通过</option>
	                  <option value="3">复审通过</option>
	                  <option value="49">复审未通过</option>
	                  <option value="59">管理员撤回</option>
	                  <option value="6">还款中</option>
	                  <option value="7">部分还款</option>
	                  <option value="8">还款成功</option>
	                </select></li>
		       		<li><span>时间</span><input type="text" name="startTime" id="startTime" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',readOnly:true})" class="searchTime"/>&nbsp;-&nbsp;<input type="text" name="endTime" id="endTime" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',readOnly:true})" class="searchTime"/></li>
		       		<li><span>&nbsp;</span><a href="javascript:void(0);" class="searchBtn sureBtn" onclick="$.fn.dataGridOptions.searchFun('#showAdw');">确定</a><a href="javascript:void(0);" class="searchBtn" onclick="$.fn.dataGridOptions.cleanFun('#searchForm');">重置</a></li>
		        </ul>
	        </form>
        </div>
        <div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
            <table id="borrowManagerList"></table>
        </div>
    </div>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>